/**
 * 	 Copyright (c) 2008, 2009 Lukas Zaruba
 * 
 *   This file is part of UniAnalyzer (Universal Analyzer).
 *
 *   UniAnalyzer is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   UniAnalyzer is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Lesser General Public License for more details.
 *
 *   You should have received a copy of the GNU Lesser General Public License
 *   along with UniAnalyzer. If not, see <http://www.gnu.org/licenses/>.
 */

package net.zarubsys.unianalyzer.dataminers.lpt.gui.parameterObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import net.zarubsys.unianalyzer.dataminers.lpt.pin.CustomizedPin;

public class LPTMeasuringSettings implements Serializable, Cloneable {
	private static final long serialVersionUID = -612904369567694020L;
	
	private List<CustomizedPin> customizedPins;
	private StartStopData startStopData;
	private PortSettings portSettigns;
	private String name;
	private String description;
	
	public LPTMeasuringSettings() {
		startStopData = new StartStopData();
		portSettigns = new PortSettings();
	}

	public List<CustomizedPin> getCustomizedPins() {
		return customizedPins;
	}

	public void setCustomizedPins(List<CustomizedPin> customizedPins) {
		this.customizedPins = customizedPins;
	}
	
	public void setStartStopData(StartStopData data) {
		this.startStopData = data;
	}
	
	public StartStopData getStartStopData() {
		return startStopData;
	}
	
	public void setPortSettings(PortSettings portSettings) {
		this.portSettigns = portSettings;
	}
	
	public PortSettings getPortSettings() {
		return portSettigns;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
	
	@Override
	public int hashCode() {
		int hash = 53;
		for (CustomizedPin pin : customizedPins) {
			hash *= pin.hashCode();
			hash += pin.hashCode();
		}
		
		if (name != null) {
			hash ^= name.hashCode();
		}
		
		if (description != null) {
			hash ^= description.hashCode();
		}
		hash *= startStopData.hashCode() ^ portSettigns.hashCode();
		return hash;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (obj == null) return false;
		if (!(obj instanceof LPTMeasuringSettings)) return false;
		if (obj.hashCode() != hashCode()) return false;
		return true;
	}
	
	@Override
	public Object clone() throws CloneNotSupportedException {
		LPTMeasuringSettings newSettings = (LPTMeasuringSettings) super.clone();
		newSettings.setName(name);
		newSettings.setDescription(description);
		List<CustomizedPin> newPins = new ArrayList<CustomizedPin>();
		for (CustomizedPin pin : customizedPins) {
			newPins.add((CustomizedPin) pin.clone());
		}
		newSettings.setCustomizedPins(newPins);
		newSettings.setStartStopData((StartStopData) startStopData.clone());
		newSettings.setPortSettings((PortSettings) portSettigns.clone());
		return newSettings;
	}
	
}


/*
 * $Log$
 */